package com.meij.activity;

import java.util.ArrayList;

import android.os.Bundle;
import android.support.v4.view.ViewPager;

import com.anno.ActionBarSet;
import com.anno.ActionBarSet.WAY;
import com.meij.R;
import com.meij.adapter.PicPagerAdapter;
import com.meij.bean.Album;
import com.meij.view.ZoomOutPageTransformer;

@ActionBarSet(title = "相册", way = WAY.TITLE, homeAsUpEnabled = true)
public class PicActivity extends MjActivity {
	private ViewPager pager;
	private ArrayList<Album> albums = new ArrayList<Album>();
	private int position;
	private PicPagerAdapter adapter;

	@SuppressWarnings("unchecked")
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_pic);
		albums = (ArrayList<Album>) getIntent().getSerializableExtra("albums");
		position = getIntent().getIntExtra("position", 0);
		initView();
	}

	/***
	 * 初始化UI
	 */
	private void initView() {
		pager = (ViewPager) findViewById(R.id.pager);
		adapter = new PicPagerAdapter(getSupportFragmentManager(), albums);
		pager.setAdapter(adapter);
		pager.setPageTransformer(true, new ZoomOutPageTransformer());
		pager.setCurrentItem(position);
	}
}
